const axiosReq = require('./axiosReq')

function wxAccessToken(appid, secret) {
  return axiosReq.get('https://api.weixin.qq.com/cgi-bin/token', {
    params: {
      grant_type: 'client_credential',
      appid: appid,
      secret: secret
    }
  }).then(res => {
    return {
      success: true,
      data: res
    }
  })
}

function wxTicket(access_token) {
  return axiosReq.get('https://api.weixin.qq.com/cgi-bin/ticket/getticket', {
    params: {
      access_token: access_token,
      type: 'jsapi'
    }
  }).then(res => {
    return {
      success: true,
      data: res
    }
  })
}

module.exports = {
  wxAccessToken,
  wxTicket
}